home *** CD-ROM | disk | FTP | other *** search
- %BEGIN Arcs
-
- % Copyright (C) 1993 David John Burrowes
- % Distributed under terms of GNU General Public License.
- % See COPYING.text in Convert PICT's CommentedPSCode for a copy
-
- %
- % Note:
- % setupForArcPath, penWidth and penHeight defined in Common file
- %
-
- %%%%%%%%%%%%%
- % Name: arcpath
- % Syntax: top left bottom right start stop arcpath -
- % About: Given the coordinates for a rectangle, a start and finish angle,
- % build a PICT style wedge/arc. Note that we rely on the Common
- % setupForArcPath to do the necessary scaling of user space.
- % Note: this uses and sets the 'global' last* variables.
- %%%%%%%%%%%%%
- /arcpath
- {
- /finishAng exch def
- /startAng exch def
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
- %
- % produce an arc-wedge along the specified angles.
- %
- newpath
- lastright lastleft sub % compute width & height
- lastbottom lasttop sub
- lastbottom lastleft setupForArcPath
- /radius exch def
- /yoffset exch def
- /xoffset exch def
- xoffset yoffset moveto
- xoffset yoffset radius startAng finishAng arc
- closepath
- }
- def
-
- %%%%%%%%%%%%%
- % Name: frameArc [0060]
- % Syntax: top left bottom right start-angle stop-angle frameArc -
- % About: Use coords of a rectangle, plus the starting and finishing
- % angle, and frames the outline of a portion of an oval's outline
- % (an arc), using the values of penWidth and penHeight.
- % If the penwidth and height are both 1, then we do a special case
- % framing, because it looks a bit better, and will doubtlessly be
- % used frequently. Otherwise, we use the setupForArcPath routine
- % to build an oval path which we then frame part of.
- % Note: to get the penwidth and heigh effect, we frame an arc inside
- % the first, and then fill the space between them.
- % Note that the last* values are modified and used here
- %%%%%%%%%%%%%
- /frameArc
- {
- /finishAng exch def
- /startAng exch def
- /lastright exch def
- /lastbottom exch def
- /lastleft exch def
- /lasttop exch def
-
- gsave
- penPattern usePattern
-
- /thewidth lastright lastleft sub def
- /theheight lastbottom lasttop sub def
- %
- % special case for pens that are 1 by 1 pixel
- %
- penHeight 1 eq
- penWidth 1 eq
- and
- {
- newpath
- thewidth theheight lastbottom lastleft setupForArcPath
- startAng finishAng arc
- stroke
- }
- {
- %
- % More general case for penwidths and heights != 1
- %
- penHeight 0 gt % We don't want to draw with a 0 sized pen.
- penWidth 0 gt
- and
- {
- /startmatrix matrix currentmatrix def
- newpath
- thewidth theheight lastbottom lastleft setupForArcPath
- startAng finishAng arc
- %
- % Recover from the distortions to user space that
- % setupForArcPath did, and calculate the dimensions
- % of an inner rectangle bounding the arc's oval.
- %
- startmatrix setmatrix
-
- /innerRight lastright penWidth sub 1 add def
- /innerTop lasttop penHeight add 1 sub def
- /innerLeft lastleft penWidth add 1 sub def
- /innerBottom lastbottom penHeight sub 1 add def
- /innerWidth innerRight innerLeft sub def
- /innerHeight innerBottom innerTop sub def
-
- innerWidth innerHeight innerBottom innerLeft
- setupForArcPath
- finishAng startAng arcn
- closepath
- fill
- }
- if
- }
- ifelse
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: paintArc [0061]
- % Syntax: t l b r start finish paintArc -
- % About: pass parameters to arcpath, and fill the resulting arc.
- %%%%%%%%%%%%%
- /paintArc
- {
- gsave
- penPattern usePattern
- arcpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseArc [0062]
- % Syntax: t l b r start finish eraseArc -
- % About: Pass params to arcpath and fill the wedge with background pat
- %%%%%%%%%%%%%
- /eraseArc
- {
- gsave
- backPattern usePattern
- arcpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: invertArc [0063]
- % Syntax: t l b r start finish invertArc -
- % About: Calls arcpath, only to get last* values stored, 'cause we
- % don't even try to invert the arc.
- %%%%%%%%%%%%%
- /invertArc
- {
- gsave
- arcpath
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: fillArc [0064]
- % Syntax: t l b r start finish fillArc -
- % About: Passes params to arcpath, and fills the resulting wedge.
- %%%%%%%%%%%%%
- /fillArc
- {
- gsave
- fillPattern usePattern
- arcpath
- fill
- grestore
- }
- def
-
- %%%%%%%%%%%%%
- % Name: frameSameArc [0068]
- % Syntax: start finish frameSameArc -
- % About: Use last* values and params to frame an arc
- %%%%%%%%%%%%%
- /frameSameArc
- {
- /endAng exch def
- /startAng exch def
- lasttop lastleft lastbottom lastright startAng endAng frameArc
- }
- def
-
- %%%%%%%%%%%%%
- % Name: paintSameArc [0069]
- % Syntax: start finish paintSameArc -
- % About: Use last* values and params to paint an arc
- %%%%%%%%%%%%%
- /paintSameArc
- {
- /endAng exch def
- /startAng exch def
- lasttop lastleft lastbottom lastright startAng endAng paintArc
- }
- def
-
- %%%%%%%%%%%%%
- % Name: eraseSameArc [006A]
- % Syntax: start finish eraseSameArc -
- % About: Use last* values and params to erase an arc
- %%%%%%%%%%%%%
- /eraseSameArc
- {
- /endAng exch def
- /startAng exch def
- lasttop lastleft lastbottom lastright startAng endAng eraseArc
- }
- def
-
- %%%%%%%%%%%%%
- % Name: invertSameArc [006B]
- % Syntax: start finish invertSameArc -
- % About: Use last* values and params to (try to) invert an arc
- %%%%%%%%%%%%%
- /invertSameArc
- {
- /endAng exch def
- /startAng exch def
- lasttop lastleft lastbottom lastright startAng endAng invertArc
- }
- def
-
- %%%%%%%%%%%%%
- % Name: fillSameArc [006C]
- % Syntax: start finish fillSameArc -
- % About: Use last* values and params to (try to) fill an arc
- %%%%%%%%%%%%%
- /fillSameArc
- {
- /endAng exch def
- /startAng exch def
- lasttop lastleft lastbottom lastright startAng endAng fillArc
- }
- def
-
- %END Arcs
-